*********************
** Table A.3: Summary statistics for children and their parents, covering demographic information, socio-economic characteristics, and information about contact with the out-group
*********************

* Group variables for producing summary statistics
decode parentEducation , gen(Str_parentEducation)
xi i.Str_parentEducation, noomit
foreach v of varlist _IStr_paren_? {
	local vlabel = substr("`: variable label `v''", strpos("`: variable label `v''","==")+2,.)
	label variable `v' `"    - `vlabel'"'
}

** Contact
global contact_cont "TimeGoingToThisSchool NumFriendsOutGroup_org TimeInJordan OriginToAmman JordanianRelatives"
global contact_bin "FriendsFromOutGroupAtSchool SyrianRelatives PalestinianRoots"

** SES Variables/Demographics
global demographics "childMale parentMale"
global SES_cont "nChildren governorateIncome"
global SES_bin "parentsHaveSmartphone parentsHaveBooks"

** Indentation
foreach v of varlist $contact_cont $contact_bin $demographics $SES_bin $SES_cont {
	label variable `v' `"   `: variable label `v''"'
}


* Generate output tables for paper

	estpost su $demographics $SES_cont _IStr_paren_? $SES_bin TimeGoingToThisSchool NumFriendsOutGroup_org FriendsFromOutGroupAtSchool
	est store all
	estpost su $demographics $SES_cont _IStr_paren_? $SES_bin TimeGoingToThisSchool NumFriendsOutGroup_org FriendsFromOutGroupAtSchool SyrianRelatives PalestinianRoots if !shift
	est store m
	estpost su $demographics $SES_cont _IStr_paren_? $SES_bin TimeGoingToThisSchool NumFriendsOutGroup_org FriendsFromOutGroupAtSchool TimeInJordan OriginToAmman JordanianRelatives if shift
	est store a

		esttab all m a using "2_output\TableA3.rtf", replace ///
			cells("mean(fmt(2)) count(fmt(0))" "sd(fmt(2) par)") collabels("Mean (SD)" "Obs.") label nonum noobs plain ///
			mtitles("[1] Full Sample" "[2] Jordanian Children/Parents" "[3] Syrian Children/Parents") ///
			mgroups("Summary Statistics", span) ///
			refcat(childMale "Demographic Information" governorateIncome "Socio-Economic Characteristics" _IStr_paren_1 "   Parental Education" TimeGoingToThisSchool "Contact Variables", nolabel) ///
			coeflabel(governorateIncome "   Avg. income in governorate^a" TimeInJordan "   Time in Jordan (yrs)^b") ///
			modelwidth(6 6 6) varwidth(33) ///
			addnote("^a: Normalized Gross National Income/Household Wealth on the governorate (subnational) level according to the Subnational Human Development Index (Smits and Permanyer, 2019)" `"^b: For "Time in Jordan", 9 observations from families that have arrived before the outbreak of the war in 2011 are not considered."')
	
* Have a nice day!
